<extend name="layout/application"/>

<block name="content">

    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">链接地址分类</strong> /
                <small>SiteCategory List</small>
            </div>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a type="button" class="am-btn am-btn-default" href="{{:Url('Sitescategory/create')}}">
                            <span class="am-icon-plus"></span> 新增
                        </a>
                    </div>
                </div>
            </div>
            <div class="am-g" style="margin-left: 45%">
                <div class="am-u-sm-12 am-u-md-12">
                    <form class="am-form-inline" role="form" method="get">

                        <div class="am-form-group">
                            <input type="text" name="name" class="am-form-field am-input-sm" placeholder="商品名"
                                   value="">
                        </div>
                        <button type="submit" class="am-btn am-btn-default am-btn-sm">查询</button>
                        <a href="{{:Url('Sitescategory/index')}}" class="am-btn am-btn-default am-btn-sm" type="button">重置</a>
                    </form>
                </div>
            </div>

        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table  am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-id">编号</th>
                            <th style="width: 20%;">分类名</th>
                            <th class="table-sort-order am-hide-sm-only" style="width:8%">排序</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <foreach $categories as $category>
                            <tr data-id="{{$category.id}}" class="xParent">
                                <td>{{$category.id}}</td>
                                <td>{{$category.name}}</td>
                                <td class="am-hide-sm-only">{{$category.sort}}</td>

                                <td>
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                               href="{{:Url('Sitescategory/edit',['id'=>$category.id])}}">
                                                <span class="am-icon-pencil-square-o"></span> 编辑
                                            </a>
                                            <a class="am-btn am-btn-default am-btn-xs delete_category am-text-danger am-hide-sm-only"
                                               href="javascript:;">
                                                <span class="am-icon-trash-o"></span> 删除
                                            </a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                </form>
                <div class="am-cf">
                    共{{:count($categories)}} 条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            {{$categories|raw}}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>


</block>

<block name="js">
    <script>
        $(".delete_category").click(function () {
            var id = $(this).parents('tr').data("id");
            var self = $(this);
            $.ajax({
                type: 'DELETE',
                url: "/admin/sitescategory/delete",
                data:{id:id},
                success: function () {
                    self.parents('tr').fadeOut(400, function () {
                        remove(self.parents('tr'));
                    });
                }
            })

        });
    </script>
</block>